package com.scriptback.repository;

import com.scriptback.entity.Project;
import com.scriptback.entity.Scripts;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 项目数据访问接口
 */
@Repository
public interface ProjectRepository extends JpaRepository<Project,String> {

    // 分页查询所有项目
    @Query("SELECT p FROM Project p  ORDER BY p.id DESC ")
    Page<Project> findAllByOrderByIdDesc(Pageable pageable);

    // 按名称模糊查询项目
    @Query("SELECT p FROM Project p WHERE UPPER(p.name) LIKE UPPER(CONCAT('%',:name,'%') ) ")
    Page<Project> findByNameContainingIgnoreCase(String name, Pageable pageable);



}
